<div class="easyui-layout" data-options="fit:true">
	<div data-options="region: 'north', border:false">
		<table cellpadding="5">
			<input name="id" type="hidden" value="${(playStartItem.id)!}" />
			<tr>
				<td class="tbLabel">庄家名称:</td>
				<td><input name="memberName" class="easyui-validatebox textbox"
					data-options="required: false"
					value="${(playStartItem.memberName)!}" /></td>
				<td class="tbLabel">开庄剩余金额:</td>
				<td><input name="account" style="width: 158px;"
					class="easyui-numberbox" precision="0"
					data-options="required: false" value="${(playStartItem.account)!}" />
				</td>
			</tr>
			<tr>

			</tr>
		</table>
	</div>
	<div data-options="region:'center',border:false">
		<table id="player_list" data-options="border:false"></table>
		<script type="text/javascript">
			var player_list = null;
			$(function() {
				player_list = $('#player_list');
				player_list.datagrid({
					url : '',
					height : 'auto',
					title : '闲家列表',
					striped : 'false',
					fit : true,
					selectOnCheck : false,
					checkOnSelect : false,
					toolbar : '#gamer_toolbar',
					loadMsg : '数据加载中，请稍等...',
					queryParams : {
						time : new Date().getTime()
					},
					rownumbers : false,
					singleSelect : true,
					idField : 'id',
					autoEditing : true,
					singleEditing : true,
					extEditing : true,
					rowContextMenu : [ {
						text : "编辑",
						iconCls : "icon-edit",
						handler : function(e, index) {
							player_list.datagrid("beginEdit", index);
						}
					} ],
					remoteSort : false,
					enableHeaderClickMenu : true,
					enableHeaderContextMenu : true,
					enableRowContextMenu : false,
					columns : [ [ {
						field : 'id',
						checkbox : true
					}, {
						field : 'memberName',
						width : 200,
						title : '玩家名称',
						sortable : true,
						editor : {
							type:'combobox',
                            options:{
                                valueField:'memberName',
                                textField:'memberName',
                                method:'get',
                                url:'playMember.do?loadCombobox',
                                required:true
                            }
						}
					}, {
						field : 'playMoney',
						width : 200,
						title : '下注金额',
						sortable : true,
						editor : {
							type : 'text'
						}
					}, ] ],
				});
			});
		</script>
		<div id="gamer_toolbar">
			<a id="250d87eb-e488-438b-9987-6096b612c471"
				href="javascript:void(0)" class="easyui-linkbutton"
				iconCls="icon-add" plain="true" onclick="addPlayer()">新增</a><a
				id="fde20c52-3b88-4429-a2a8-2fb2632b4bce" href="javascript:void(0)"
				class="easyui-linkbutton" iconCls="icon-remove" plain="true"
				onclick="removePlayer()">删除</a>
		</div>

	</div>
</div>
<script>
	var i = 0, getCodeValueRow = function() {
		return {
			memberName : "",
			playMoney : 20
		};
	};
	function addPlayer() {
		player_list.datagrid("appendRow", getCodeValueRow());
	}
	function removePlayer() {
		var rows = player_list.datagrid('getChecked');
		if (rows && rows.length > 0) {
			$.messager.confirm('询问', '你确认要删除记录吗?', function(r) {
				if (r) {
					for ( var i = rows.length - 1; i >= 0; i--) {
						var index = player_list
								.datagrid('getRowIndex', rows[i]);
						player_list.datagrid('deleteRow', index);
					}
				}
			});
		} else {
			showMsg("请选择操作记录.");
		}
	}
	
	function savePlayGameStart() {
		printLog('------------')
		var rows = player_list.datagrid('getRows');
    	var data = {
    		startId:${(playStartItem.id)!},
    		memberName:'${(playStartItem.memberName)!}',
    		account:${(playStartItem.account)!},
			player:rows
    	};
    	$.post("playStart.do?saveGamePlayInfo", data, function(result) {
               if(result.success){
            	  showMsg('保存成功.');
            	  reloadStartPlayCenterMember();
               }else {
            	   showMsg('保存失败.');
               }
       }, "JSON");
	}
</script>
